<!--新建规则集合-->
<template>
  <el-dialog  :visible.sync="open" width="600px" :close-on-click-modal="false" append-to-body>
    <el-form ref="ruleForm" style="margin: 0 auto;width: 50%;" label-width="auto">
      <el-form-item label="规则集合名称：" prop="name">
        <el-input v-model="result.name" placeholder="0" style="width: 330px" prop="name"></el-input>
      </el-form-item>
      <el-button type="primary" @click="addRuleCollection">提交</el-button>
    </el-form>
  </el-dialog>

</template>
<script>
import api from '@/api/monitor/collection'
export default {
  data() {
    return {
      open: false,
      // 弹出层标题
      title: "规则集合",
      result:{
        hiveDatabase: "",
        hiveTableName: "",
        name: ""
      }
    };
  },
  mounted() {
    this.init()
  } ,
  methods: {
    init(tableName,dbName) {
      this.result.hiveDatabase = dbName;
      this.result.hiveTableName = tableName;
      this.open = true;
      this.title = "预览执行计划";
    },
    //添加规则集合
    addRuleCollection(){
      api.createCollection(this.result).then((response) => {
        if (response.code == 200) {
          this.$notify({
            title: '成功',
            message: '创建成功',
            type: 'success',
            duration: 2000
          })
          this.open = false;
          // window.parent.location.reload(); //刷新父页面
          // this.$parent.$refs;
          parent.location.reload();
          this.$emit("fevent")
        } else
          "错误";
        // })
        //   this.result = response;
        // })
        //   .catch((response) => {
        //     console.log("失败" + response);
        //     // Vue.$message.error('服务器错误，请稍后再试')
        //     //reject(response)
      });
    }
  }
}
</script>



